package com.lx;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

public class hashmap {
    public static void main(String[] args) {
        student s1 = new student("lx",25);
        student s2 = new student("lix",24);
        student s3 = new student("lab",25);
        student s4 = new student("lab",25);
        Map<student,String> map = new HashMap<>();
        map.put(s1,"辽宁");
        map.put(s2,"浙江");
        map.put(s3,"深圳");
        map.put(s4,"上海");

        Set<student> students = map.keySet();
        for (student student : students) {
            String value = map.get(student);
            System.out.println(student+"="+value);
        }
        Set<Map.Entry<student, String>> entries = map.entrySet();
        for (Map.Entry<student, String> entry : entries) {
            System.out.println(entry.getKey());
            System.out.println(entry.getValue());
        }

        map.forEach(new BiConsumer<student, String>() {
            @Override
            public void accept(student student, String s) {
                System.out.println(student+"="+s);
            }
        });

    }
}
